package org.andcool.util;

import android.app.Activity;
import android.view.Window;
import android.view.WindowManager;

/**
 * @author Joosun
 * @since 2011-5-6
 */
public class ActivityUtils
{
	public static void requestNoTitlescreen(final Activity pActivity)
	{
		final Window window = pActivity.getWindow();
		window.requestFeature(Window.FEATURE_NO_TITLE);
	}

	public static void requestFullscreen(final Activity pActivity)
	{
		final Window window = pActivity.getWindow();
		window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
		window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
		window.requestFeature(Window.FEATURE_NO_TITLE);
	}

	public static void setScreenBrightness(final Activity pActivity, final float pScreenBrightness)
	{
		final Window window = pActivity.getWindow();
		final WindowManager.LayoutParams windowLayoutParams = window.getAttributes();
		windowLayoutParams.screenBrightness = pScreenBrightness;
		window.setAttributes(windowLayoutParams);
	}

	public static void keepScreenOn(final Activity pActivity)
	{
		final Window window = pActivity.getWindow();
		window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
	}
}